<template>
  <div>
    <city-header></City-header>
    <search :cities='cities'></search>
    <list :hotCities='hotCities' :cities='cities' :letter="letter"></list>
    <City-alphabet :cities='cities' @change="jumpwhere"></City-alphabet>
  </div>
</template>

<script>
import axios from 'axios'
import CityHeader from './components/Header.vue'
import search from './components/search.vue'
import list from './components/list.vue'
import CityAlphabet from './components/CityAlphabet.vue'
export default {
  name: 'City',
  components: {
    CityHeader,
    search,
    list,
    CityAlphabet
  },
  data () {
    return {
      cities: {},
      hotCities: [],
      letter: ''
    }
  },
  methods: {
    getCityInfo () {
      axios.get('/api/city.json').then(this.handelGetCityInfoSucc)
    },
    handelGetCityInfoSucc (res) {
      res = res.data
      if (res.ret && res.data) {
        const data = res.data
        this.hotCities = data.hotCities
        this.cities = data.cities
      }
    },
    jumpwhere (letter) {
      this.letter = letter
    }
  },
  mounted () {
    this.getCityInfo()
  }
}
</script>

<style>
</style>
